package com.yunbao.hujin.myzoomcenter;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.ViewFlipper;

import com.yunbao.hujin.myzoomcenter.marqueeText.MarqueeView;

import java.util.ArrayList;
import java.util.List;

public class TextActivity extends AppCompatActivity {

    MarqueeView marqueeView;         //上下滚动消息
    MarqueeView marqueeView2;         //上下滚动消息
    MarqueeView marqueeView3;         //上下滚动消息
    ViewFlipper viewFlipper;
    private List<String> data;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_text);

        setMarqueeView();
        setMarqueeView2();
        setMarqueeView3();

        setFilpperView();
    }

    //处理上下滚动消息
    private void setMarqueeView() {
        marqueeView = findViewById(R.id.marqueeText);
        data = new ArrayList<>();
        data.add("注册就送苹果X");
        data.add("上面那条新闻是假的");
//        data.add("。。。。。。");
        marqueeView.setData(data);
    }

    //处理上下滚动消息
    private void setMarqueeView2() {
        marqueeView2 = findViewById(R.id.marqueeText2);
        data = new ArrayList<>();
        data.add("注册就送苹果X");
//        data.add("上面那条新闻是假的");
        data.add("。。。。。。");
        marqueeView2.setData(data);
    }

    //处理上下滚动消息
    private void setMarqueeView3() {
        marqueeView3 = findViewById(R.id.marqueeText3);
        data = new ArrayList<>();
        data.add("注册就送苹果X");
        data.add("上面那条新闻是假的");
        data.add("。。。。。。");
        marqueeView3.setData(data);
    }

    public void stop(View view) {
        marqueeView.stop();
    }


    private void setFilpperView() {
        viewFlipper = findViewById(R.id.flipper);
        for (int i =0;i<4;i++) {
            //自定义view布局
//            View view = LayoutInflater.from(this).inflate(R.layout.layout_custom, null);
//            viewFlipper.addView(view);
            TextView textView = new TextView(this);
            textView.setText("这是第" + i + "滚动条");
            textView.setTextColor(Color.BLACK);
            textView.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.home_radio, 0, 0, 0);
            textView.setCompoundDrawablePadding(10);
            textView.setPadding(0, 10, 10, 0);
            viewFlipper.addView(textView);
        }
    }
}
